package com.gupao.orderssoclient;

import com.gupao.orderssoclient.interceptor.SessionInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication
public class OrderSsoClientApplication extends WebMvcConfigurerAdapter{

	public static void main(String[] args) {
		SpringApplication.run(OrderSsoClientApplication.class, args);
	}

	/**
	 * 这里 写拦截器的要拦截的路径。   要是写切面就不用写这个啦。。。
	 * @param registry
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(sessionInterceptor()).addPathPatterns("/order/*");
	}

	@Bean
	public SessionInterceptor sessionInterceptor(){
		return new SessionInterceptor();
	}
}
